n=int(input())
numbers=list(map(int,input().split()))

result=0

s={-2}
for number in numbers:
    s.add(number)
    little=number-1
    if little in s:
        result+=1
    large=number+1
    if large in s:
        result+=1

print(result)